package com.huitian.mobileshop.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.webkit.CookieManager;

import com.huitian.mobileshop.Links;
import com.huitian.mobileshop.R;

public class LaunchActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final View view=View.inflate(this, R.layout.activity_launch, null);
		setContentView(view);
		AlphaAnimation aa=new AlphaAnimation(0.3f, 1.0f);
		aa.setDuration(2000);
		view.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			
			@Override
			public void onAnimationStart(Animation arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationRepeat(Animation arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationEnd(Animation arg0) {
				// TODO Auto-generated method stub
				startMainActivity();
			}
		});
	}
	
	//开启主界面的方法
	public void startMainActivity(){
	
				
				String localcookie=CookieManager.getInstance().getCookie(Links.HOST);
				Intent intent=new Intent(LaunchActivity.this, MainActivity.class);
				if(localcookie==null||localcookie.equals("")||!localcookie.contains("customercode")){
					intent.putExtra(MainActivity.TITLE, "手机验证登录").putExtra(MainActivity.URL, Links.LOGIN).putExtra(MainActivity.USERBUTTON, View.GONE);
				}else {
					intent.putExtra(MainActivity.TITLE, "商品大全")
					.putExtra(MainActivity.URL, Links.MAIN)
					.putExtra(MainActivity.USERBUTTON, View.VISIBLE)
					.putExtra(MainActivity.BACKBUTTON, View.GONE);
				}
				startActivity(intent);
				LaunchActivity.this.finish();
	
	}
}
